package com.xpqh.ksg.common.persistence.dao;

import com.xpqh.ksg.common.persistence.model.KsgStockInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2025-04-16
 */
public interface KsgStockInfoMapper extends BaseMapper<KsgStockInfo> {

    @Select("select office_code storeId,signal_id signalId from ksg_stock_info where signal_id = #{signalId}")
    KsgStockInfo getBySignalId(String signalId);


    @Update("update ksg_stock_info set distribute_type = 1,distribute_time = now(),office_code = #{storeId} where signal_id = #{signalId}")
    Integer updateStockDistributeType(@Param("signalId")String signalId, @Param("storeId")String storeId);



    @Insert("INSERT INTO ksg_stock_record ( `signal_id`, `store_id`, `create_time`, `user_code`, `operation_type`) " +
            "values (#{signalId},#{storeId},now(),#{userCode},#{operationType},)")
    Integer insertStockRecord(@Param("signalId")String signalId, @Param("storeId")String storeId,@Param("userCode")String userCode,@Param("operationType")String operationType);

}

